package com.fsquare.controller.contact;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;


@Component("blContactValidator")
public class ContactValidator implements Validator  {

    public boolean supports(Class clazz) {
        return clazz.equals(ContactForm.class);
    }

    @Override
	public void validate(Object obj, Errors errors) {
//    	validate(obj, errors, true);
    	
    	ValidationUtils.rejectIfEmpty(errors, "name", "name.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "emailAddress.required");
		ValidationUtils.rejectIfEmpty(errors, "message", "message.required");
    }
    
//	public void validate(Object obj, Errors errors, boolean validCaptcha) {
//		ContactForm form = (ContactForm) obj;
//		
//	}

}
